import wepy from 'wepy'

export default class extends wepy.mixin {
  methods = {}

  data = {
    swiperData: [],
    catesData: [],
    floorData: []
  }

  methods = {
    goGoodsList(url) {
      wepy.navigateTo({
        url
      })
    }
  }

  onLoad() {
    this.getSwiperData()
    this.getCatesData()
    this.getFloorData()
  }

  async getSwiperData() {
    let {data: res} = await wepy.get('/home/swiperdata')

    if( res.meta.status !== 200 ) {
      return wepy.baseToast()
    }

    this.swiperData = res.message 

    this.$apply()
  }

  async getCatesData() {
    let {data: res} = await wepy.get('/home/catitems')

    if( res.meta.status !== 200 ) {
      return wepy.baseToast()
    }

    this.catesData = res.message 

    this.$apply()
  }

  async getFloorData() {
    let {data: res} = await wepy.get('/home/floordata')

    if( res.meta.status !== 200 ) {
      return wepy.baseToast()
    }

    this.floorData = res.message 

    this.$apply()
  }
}